package com.software.practicecenter.controller;

import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.software.practicecenter.entity.KnowledgePoint;
import com.software.practicecenter.entity.MasterLevel;
import com.software.practicecenter.service.MasterLevelService;
import com.software.practicecenter.utils.GsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @Author xiaoliao
 * @Date 2023/6/2 15:11
 */
@RestController
@RequestMapping("/master_level")
@RefreshScope
public class MasterLevelController {
    @Autowired
    private MasterLevelService masterLevelService;

    @RequestMapping("/findByUserIdAndKnowledgeIdIn")
    public List<MasterLevel> findByUserIdAndKnowledgeIdIn (@RequestBody Map<String,String> map) {
        String userId = map.get("userId");
        String json = map.get("ids");
        Collection<String> ids = GsonUtils.gson.fromJson(json,  new TypeToken<List<String>>(){}.getType());
        return masterLevelService.findByUserIdAndKnowledgeIdIn(userId, ids);
    }


}
